package chain

import (
	"blockchain/block"
)

type Blockchain struct {
	Blocks []*block.Block
}

func (bc *Blockchain) AddBlock(data string) {
	prevBlock := bc.Blocks[len(bc.Blocks)-1]
	newBlock := block.NewBlock(data, prevBlock.Hash)
	bc.Blocks = append(bc.Blocks, newBlock)
}

func NewBlockChain() *Blockchain {
	return &Blockchain{
		Blocks: []*block.Block{block.NewGenesisBlock()},
	}
}
